#[cfg(test)]
mod tests {
    use hysteria_core::protocol::{TcpRequest, TcpResponse, UdpMessage};
    use hysteria_core::crypto::SalamanderObfuscator;

    #[test]
    fn test_tcp_request_encoding() {
        let req = TcpRequest::new("example.com:443".to_string());
        let encoded = req.encode();
        let decoded = TcpRequest::decode(&encoded).unwrap();
        assert_eq!(decoded.address, "example.com:443");
    }

    #[test]
    fn test_tcp_response_encoding() {
        let resp = TcpResponse::ok();
        let encoded = resp.encode();
        let decoded = TcpResponse::decode(&encoded).unwrap();
        assert!(decoded.is_ok());
    }

    #[test]
    fn test_udp_message_encoding() {
        let msg = UdpMessage::new(12345, "8.8.8.8:53".to_string(), vec![1, 2, 3, 4]);
        let encoded = msg.encode();
        let decoded = UdpMessage::decode(&encoded).unwrap();
        
        assert_eq!(decoded.session_id, 12345);
        assert_eq!(decoded.address, "8.8.8.8:53");
        assert_eq!(decoded.payload, vec![1, 2, 3, 4]);
    }

    #[test]
    fn test_salamander_obfuscation() {
        let obfuscator = SalamanderObfuscator::new("test_password");
        let original = b"Hello, World! This is a test message.";

        let obfuscated = obfuscator.obfuscate(original);
        assert_ne!(&obfuscated[8..], original);

        let deobfuscated = obfuscator.deobfuscate(&obfuscated).unwrap();
        assert_eq!(&deobfuscated, original);
    }

    #[test]
    fn test_salamander_different_passwords() {
        let obf1 = SalamanderObfuscator::new("password1");
        let obf2 = SalamanderObfuscator::new("password2");
        let original = b"Test data";

        let obfuscated = obf1.obfuscate(original);
        let result = obf2.deobfuscate(&obfuscated).unwrap();
        
        // Different password should produce different result
        assert_ne!(&result, original);
    }
}
